﻿using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;


namespace 自定义配置系统
{
    public class LmConfigProvider:FileConfigurationProvider
    {
        public LmConfigProvider(LmConfigSource src):base(src)
        {
            
        }
        public override void Load(Stream stream)
        {
            var data = new Dictionary<string, string?>();
            var reader = new StreamReader(stream);
            var fileInfo =  reader.ReadToEnd();
            JObject jobject = (JObject)JToken.Parse(fileInfo);
            foreach (var item in jobject)
            {
                data.Add(item.Key, item.Value.ToString());
            }
            this.Data = data;
        }
    }
}
